package cn.hjd.service.impl;

import java.util.Collections;
import java.util.List;

import cn.hjd.dao.DelayDao;
import cn.hjd.dao.impl.DelayDaoImpl;
import cn.hjd.po.ApproveList;
import cn.hjd.po.PageResult;
import cn.hjd.query.ApproveListQuery;
import cn.hjd.service.DelayService;

public class DelayServiceImpl implements DelayService {
	
	private DelayDao dao = new DelayDaoImpl();
	
	public PageResult list(ApproveListQuery qo) {
		//查询 用户总数
		Integer totalCount = dao.findTotalCountByCondition(qo);
		//创建PageResult 对象，用于封装列表页面的所有数据（包括分页相关信息）
		PageResult pageResult = null;
		//如果查询的总数大于0条就去查询数据列表，如果等于0 就没必要去查询了
		if (totalCount != 0) {
			//根据条件查询数据列表
			List<ApproveList> aList = dao.findByCondition(qo);
			pageResult = new PageResult(aList, totalCount,qo.getPageSize(),qo.getCurrentPage());
		}else {
			pageResult = new PageResult(Collections.EMPTY_LIST, 0, qo.getPageSize(), qo.getCurrentPage());
		}
		
		
		return pageResult ;
	}

	@Override
	public int updateApprove(ApproveList approveList) {
		// TODO Auto-generated method stub
		return dao.updateApprove(approveList);
	}

	@Override
	public int save(ApproveList approveList) {
		// TODO Auto-generated method stub
		return dao.insert(approveList);
	}

	@Override
	public int deleteUser(Integer id) {
		// TODO Auto-generated method stub
		return dao.deleteById(id);
	}
	
}
